package com.szrt.java.day20161228.demo02;

import java.util.Arrays;


/**
 * 80%  冒泡排序
 * @author zsrt
 *
 */



public class PopSort03 {
	
	public static void popSort(int[] arrays){
		int len = arrays.length;
		for(int outer=1;outer<=len-1;outer++){
			for(int inner=1;inner<=len-outer;inner++){
				//关键代码
				int first = inner-1;
				int second =inner;
				if(arrays[first]>arrays[second]){
					int temp = arrays[first];
					arrays[first]= arrays[second];
					arrays[second] =temp;
				}
			}
		}
	}
	
	public static void main(String[] args) {
		int[] arrays ={90,80,70,60,50,40,30};
		PopSort03.popSort(arrays);
		System.out.println(Arrays.toString(arrays));
	}

}
